<template>

    <el-dialog
        title="审核"
        :visible.sync="isExamineDialogVisible"
        width="30%"
        :before-close="hideExamineDialogVisible"
        center>
        <el-radio-group v-model="examineResult">
            <el-radio :label="2">通过</el-radio>
            <el-radio :label="3">不通过</el-radio>
        </el-radio-group>
        <div v-show="examineResult === 3">
            <el-input v-model.trim = "examineReason" placeholder="请输入审核原因" maxlength='100' class="inputTxtWrapper marT20"></el-input>
            <p class="tipRed">审核不通过需要填写原因</p>
        </div>
        
        <span slot="footer" class="dialog-footer">
            <el-button @click="hideExamineDialogVisible">取 消</el-button>
            <el-button type="primary" @click="examineProAnaly">确 定</el-button>
        </span>
    </el-dialog>

</template>

<script>
import http from '@/assets/js/http'
import _g from '@/assets/js/global'

export default {
    mixins: [http],
    props:{
        isExamineDialogVisible : {
            type : Boolean,
            required:true,
            default:false
        },
        currRowRecord:{
            type:Object,
            default : null,
        }

    },
    data(){
        return{
            examineResult:2,//审核结果
            examineReason:''//审核原因
        }
    },
    methods: {
        /* 关闭审核弹框 */
        hideExamineDialogVisible() {
            this.examineResult = 2
            this.examineReason = ''
            this.$emit('hideExamineDialogVisible')
        },
        /* 审核取消立项分析 */
        examineProAnaly(){
            const that = this
            const examineResult = this.examineResult//审核结果
            const examineReason = this.examineReason//审核原因
            const proAnalyId = that.currRowRecord.proAnalyId//  所属立项分析id
            const auditType = that.currRowRecord.auditType//    审核类型
            // const index = that.currRowRecord.index
            if(examineResult === 3 && examineReason === ''){//..如果审核不通过且没有填写审核原因
                return
            }
            
            that.$confirm('是否确认提交?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
                center: true
            }).then(() => {
                    _g.showLoading('提交中')
                    that.apiPost('admin/task/examineProAnaly', {proAnalyId,examineResult,examineReason,auditType}).then((res) => {
                        _g.showLoading().close()
                        if(typeof res === 'string'){
                            res = JSON.parse(res)
                        }
                        if (res.code != 200) {
                            that.handleError(res)
                        } else {
                            if(res.data.isSuccess === 0){             //  成功
                                _g.toastMsg("success", res.message)

                                that.hideExamineDialogVisible()
                            }else if(res.data.isSuccess === 1){
                                _g.toastMsg("error", res.message)
                            }
                        }
                    })
            }).catch(() => {});
        },
    },
}
</script>

<style scope="less">
</style>

